package control;

import java.util.List;
import java.util.Map;

import service.TopicService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import domain.Topic;

public class TopicAction extends  ActionSupport {
	private TopicService topicService;
	private String message_content;
	private int item_id;
	
	
	public int getItem_id() {
		return item_id;
	}

	public void setItem_id(int item_id) {
		this.item_id = item_id;
	}

	public String getMessage_content() {
		return message_content;
	}

	public void setMessage_content(String message_content) {
		this.message_content = message_content;
	}

	

	public TopicService getTopicService() {
		return topicService;
	}

	public void setTopicService(TopicService topicService) {
		this.topicService = topicService;
	}

	public String insertTopic(){
		Map session = ActionContext.getContext().getSession();
		Map request = (Map)	ActionContext.getContext().get("request");
//		if()
		String post_acc =(String)session.get("acc");
		System.out.println(message_content);
		topicService.insertTopic(message_content, item_id, post_acc );
		
		return SUCCESS;
	}
	
	public String showTopic(){
//		System.out.println(item_id);
		List<Topic> topics = topicService.showTopic(item_id);
		Map request = (Map)	ActionContext.getContext().get("request");
		request.put("topics", topics);
		return SUCCESS;
	}
}
